<%@page import="com.news.exception.UserPwdException"%>
<%@page import="com.news.exception.UserBCZException"%>
<%@page import="com.news.dao.impl.UserDaoImpl"%>
<%@page import="com.news.dao.UserDao"%>
<%@page import="com.news.entity.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
///乱码处理方法
request.setCharacterEncoding("utf-8");
String username=request.getParameter("username");
String password=request.getParameter("pwd");
User user=new User();
user.setUsername(username);
user.setPassword(password);
UserDao userdao=new UserDaoImpl();

try{
user= userdao.checkUser(user);
out.print("来自"+user.getFrom()+"用户"+user.getUsername()+"登录成功");
//成功后，应该进入首页
 request.getRequestDispatcher("/WEB-INF/manager.jsp").forward(request, response);
//失败后，应该回到登录页，并显示一下错误内容
}catch(UserBCZException e){
	out.print("用户名不存在");
	 request.getRequestDispatcher("/login.jsp").include(request, response);
}
catch(UserPwdException e){
	out.print("密码错误");
	 request.getRequestDispatcher("/login.jsp").include(request, response);
}

%>
</body>
</html>